/***********************************************
 This file is part of redia-bapps-main-ios.
 
 Copyright (c) 2015 Redia A/S
 
 Redia-bapps-main-ios is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 Redia-bapps-main-ios is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with redia-bapps-main-ios.  If not, see <http://www.gnu.org/licenses/>.
 
 *********************************************** */

//
//  BAReservation.m
//  redia-bapps-ios
//
//  Created by Henrik Lynbech on 18/08/13.
//  Copyright (c) 2013 redia. All rights reserved.
//

#import "BAReservation.h"
#import "JSONEncodingHelperMethods.h"

@implementation BAReservation

+ (id)objectWithJSONObject:(NSDictionary *)jsonObj
{
    BAReservation *obj = [BAReservation new];
    
    obj.title = [JSONEncodingHelperMethods parseStringWithKey:@"title" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.title);
    obj.faust = [JSONEncodingHelperMethods parseStringWithKey:@"faust" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.faust);
    obj.pickUpBranch = [JSONEncodingHelperMethods parseStringWithKey:@"pickUpBranch" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.pickUpBranch);
    // FIXME: backend provides wrong type
    obj.pickUpNo = [JSONEncodingHelperMethods parseStringWithKey:@"pickUpNo" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.pickUpNo);
     
    obj.pickUpExpireDate = [JSONEncodingHelperMethods parseIntegerWithKey:@"pickUpExpireDate" fromJsonObject:jsonObj];
    obj.queueNo = [JSONEncodingHelperMethods parseIntegerWithKey:@"queueNo" fromJsonObject:jsonObj];
    
    obj.reservationRemoveId = [JSONEncodingHelperMethods parseStringWithKey:@"reservationRemoveId" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.reservationRemoveId);
    obj.note = [JSONEncodingHelperMethods parseStringWithKey:@"note" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.note);
    obj.status = [JSONEncodingHelperMethods parseStringWithKey:@"status" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSString, obj.status);

    obj.isReady = [JSONEncodingHelperMethods parseBoolWithKey:@"isReady" fromJsonObject:jsonObj];
    
    obj.creators =  [JSONEncodingHelperMethods parseArrayOfStringsWithKey:@"creators" fromJsonObject:jsonObj];
    EXPECT_OBJECT(NSArray, obj.creators);
    
    return obj;
}

-(NSDictionary *)toJSONObject{
    DLog(@"Not implemented");
    return nil;
}

@end
